var res=location.search;
var num=parseInt(res.charAt(4));
$.get("http://193.112.55.79:9090/api/getcategorybyid",{"categoryid":num},function(res){
    console.log(res.result);
    var data=res.result;
    var a=template("temp",{"data":data});
    $(".title").html(a);
    var nun=data[0].categoryId;
    var id=parseInt($("option").val());
    $.get("http://193.112.55.79:9090/api/getproductlist",{"categoryid":nun,"pageid":id},function(res){
        var data=res.result;
        var b=template("temp1",{"data":data});
        $(".content").html(b);       
    },"json") 
},"json");
var btn2=document.querySelector(".btn2");
var btn1=document.querySelector(".btn1");
var option=document.querySelectorAll("option");
btn2.addEventListener("touchstart", function () {
    var id=parseInt($('option:selected').val());
    console.log(id);
    id++;
 if(id<=3){
    $.get("http://193.112.55.79:9090/api/getproductlist",{"categoryid":0,"pageid":id},function(res){
     var data=res.result;
     var b=template("temp1",{"data":data});
     $(".content").html(b);
    $('option').eq(id-1).prop('selected',true);
 },"json")
 }else{
     alert("数据结束");
 }
});
btn1.addEventListener("touchstart", function () {
    var id=parseInt($('option:selected').val());
    id--;
    if(id<1){
        alert("这是第一页");
    }else{
        $.get("http://193.112.55.79:9090/api/getproductlist",{"categoryid":0,"pageid":id},function(res){
            var data=res.result;
            var b=template("temp1",{"data":data});
            $(".content").html(b); 
            $('option').eq(id-1).prop('selected',true);
        },"json")
    }
});
$("#lele").change(function(){
    var id=parseInt($(this).children('option:selected').val());
    $.get("http://193.112.55.79:9090/api/getproductlist",{"categoryid":0,"pageid":id},function(res){
            var data=res.result;
            var b=template("temp1",{"data":data});
            $(".content").html(b);
            $('option').eq(id-1).prop('selected',true);
        },"json")
})
console.log($('option:selected').val());